package be.kuleuven.mume.hulpklassen;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;

public class RetainListActivity<DataType> extends Activity{
    private List<DataType> items;
    
    public List<DataType> getItems() {
    	return items;
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	tryLoadItems();
    }
    
	@SuppressWarnings("unchecked")
	private void tryLoadItems() {
		Object o = getLastNonConfigurationInstance();
		if(o == null)
			items = new ArrayList<DataType>();
		else
			items = (ArrayList<DataType>)o;
	}

	@Override
	public Object onRetainNonConfigurationInstance() {
		return items;
	}
}
